package bstsetcode;

/**
 * 递归求解
 * @author noob
 * @version 1.0
 * @date 2021/3/15 12:54
 */
public class Solution4 {

    public ListNode removeElements(ListNode head, int val) {
        if(head == null){
            return null;
        }


        ListNode res = removeElements(head.next,val);
        return head.val == val? head.next:head;

    }







    public static void main(String[] args) {
        int[] nums = {1,2,6,3,4,5,6};
        ListNode head = new ListNode(nums);
        System.out.println(head);

        ListNode res = (new Solution4()).removeElements(head,6);
        System.out.println(res);
    }
}
